package Controls
{
	import Input.GameInput;
	
	import Objects.GameSprite;
	
	import flash.ui.Mouse;

	public class LinkButton extends GameSprite
	{
		private var onColor:uint=0;
		private var overColor:uint=0;
		private var downColor:uint=0;
		public var label:Label;
		public function LinkButton()
		{
			super();
			
			intelligent=true;
			
			buttonCursor=true;
			
			label=new Label();
			label.format.underline=true;
			addChild(label);
		}
		public function setup(_onColor:uint,_overColor:uint=0,_downColor:uint=0):void
		{
			onColor=_onColor;
			if(_overColor)
			{
				overColor=_overColor;
			}
			else
			{
				overColor=onColor;
			}
			if(_downColor)
			{
				downColor=_downColor;
			}
			else
			{
				downColor=overColor;
			}
			setColor(onColor);
		}
		override protected function $update():void
		{
			if(!selected)
			{
				if(mOver)
				{
					if(mDown)
					{
						setColor(downColor);
					}
					else
					{
						setColor(overColor);
					}
				}
				else
				{
					setColor(onColor);
				}
			}
			else
			{
				setColor(downColor);
			}
		}
		private function setColor(color:uint):void
		{
			if(label.format.color==color)return;
			label.format.color=color;
			label.textField.setTextFormat(label.format);
		}
	}
}